/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entreprise;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;
import mapping.DBService;

/**
 *
 * @author Quoc-Khai
 */
public class ServiceService {
    public boolean createService(int serviceID, String serviceName, String servicePrice, String serviceDescription) throws SQLException{
        DBService dbService = new DBService();
        Service iService = new Service();
        iService = dbService.getService(serviceID);
        if (iService.getServiceID().length() <= 0) {
            iService.setServiceName(serviceName);
            iService.setServicePrice(servicePrice);
            iService.setServiceDescription(serviceDescription);
            
            dbService.createService(iService);
            return true;
        }
        
        System.out.println("Service existe!");
        return false;
    }
    public boolean deleteService(int serviceID) throws SQLException{
        DBService dbService = new DBService();
        Service iService = new Service();
        iService = dbService.getService(serviceID);
        if (iService.getServiceID().length() > 0) {
            dbService.deleteService(serviceID);
            return true;
        }
        
        System.out.println("Service not existe!");
        return false;
    }
    public boolean updateService(int serviceID, String serviceName, String servicePrice, String serviceDescription) throws SQLException{
        DBService dbService = new DBService();
        Service iService = new Service();
        iService = dbService.getService(serviceID);
        if (iService.getServiceID().length() > 0) {
            iService.setServiceID(String.valueOf(serviceID));
            iService.setServiceName(serviceName);
            iService.setServicePrice(servicePrice);
            iService.setServiceDescription(serviceDescription);
            
            dbService.updateService(iService);
            return true;
        }
        
        System.out.println("Service not existe!");
        return false;
    }
    public List<Service> findServices(String serviceName){
        List<Service> services=null;
        return services;
    }
}
